Metadata-Version: 2.1
Name: Automate-LinkedIn
Version: 0.1.0
Summary: UNKNOWN
Home-page: https://github.com/SelmiAbderrahim/automate-linkedin
Author: Selmi Abderrahim
Author-email: contact@selmi.tech
License: MIT
Keywords: linkedin bot built with Python and Selenium
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Description-Content-Type: text/markdown
License-File: LICENCE

## LinkedIn Python Bot

I built this project because I'm super lazy to check my LinkedIn account. <br>So by using this bot, I'll increase my profile views, interactions, followers, and connections.<br>
And since I love sharing my stuff with others, I created this package. 
So if you enjoy it, start it on [GitHub](https://github.com/SelmiAbderrahim/automate-linkedin).

<br><br><br>

   
- [Features](#features)
- [Installation](#installation)
- [Usage options](#usage-options)
    - [2.1. Create driver](#21-create-driver)
    - [2.2. Login](#22-login)
- [1. Posts Interactions](#1-posts-interactions)
  - [CLI](#cli)
  - [API](#api)
- [2. publishing](#2-publishing)
  - [CLI](#cli-1)
  - [API](#api-1)
- [3. Network](#3-network)
  - [3.1. Follow people](#31-follow-people)
    - [CLI](#cli-2)
    - [API](#api-2)
  - [3.2. Connect with people](#32-connect-with-people)
    - [CLI](#cli-3)
    - [API](#api-3)
- [4. Environment variables](#4-environment-variables)


<br><hr><br>

# Features

- Interact with LinkedIn posts.
  - Like
  - Comment
- Auto post/image publishing
   
# Installation

```
pip install automate-linkedin
```

or

```
pip install git+https://github.com/SelmiAbderrahim/automate-linkedin
```

# Usage options

1. CLI 

You can use these features throught the command line interface (CLI), which is quite useful to run it on a server. 

```
$ autoln OPTIONS
```

**options:**

- **username**: Your LinkedIn email address (required).
- **password**: Your LinkedIn email password (required).
- **env**: Get username & password as environment variables. **(optional)**.
- **headless**: Hide the browser's window. **(optional)**.

2. API

You can use the same features on your own project (code) throught the API.

 ```
 from automate_linkedin.interactions import Posts
 class Interaction(Posts):
     pass
 ```


For the LinkedIn authentication, I'm using the [easy_selenium](https://pypi.org/projects/easy-py-selenium) to create a Chrome driver and login to LinkedIn accounts.

### 2.1. Create driver

```
from easy_selenium.driver.chrome.driver import Driver
driver = Driver()
chrome = driver.create(headless=headless)
```

### 2.2. Login 

```
from easy_selenium.authentication.login.linkedin import Login
login = Login(username, password)
authenticated = login.start(chrome)
```


<br><hr><br>




# 1. Posts Interactions

## CLI

Interact with the LinkedIn 'home page' or 'groups' posts.

**Options**
- **post-interaction**: Interact with your LinkedIn posts. (required).

  > ```autoln --username plain_text_email --password plain_text_password --post-interaction```

- **post-number-likes**: Number of post likes  [default: 5] (required).

  > ```autoln --username plain_text_email --password plain_text_password --post-interaction --post-number-likes 10```

- **env**: Get username & password as environment variables. **(optional)**.

  > ```autoln --env --username LINKEDIN_EMAIL_ADDRESS --password LINKEDIN_PASSWORD --post-interaction```

- **headless**: Hide the browser's window. **(optional)**.

  > ```autoln --env --headless --username LINKEDIN_EMAIL_ADDRESS --password LINKEDIN_PASSWORD --post-interaction```

- **comment-number-likes**: The number of likes of comments. **(optional)**.

- **like-post-comments**: Like comments of each posts. **(optional)**.

  > ```autoln --env --headless --username LINKEDIN_EMAIL_ADDRESS --password LINKEDIN_PASSWORD --post-interaction --like-post-comments --comment-number-likes 2```

- **auto-comment**: Comment with positive examples. **(optional)**.

  > ```autoln --env --headless --username LINKEDIN_EMAIL_ADDRESS --password LINKEDIN_PASSWORD --post-interaction --auto-comment```

💡 **Example:** If I want to run a headless browser to like 20 posts and comment on any of these posts if possible.

```
autoln --env --headless --username LINKEDIN_EMAIL_ADDRESS --password LINKEDIN_PASSWORD --post-interaction --auto-comment post-number-likes 25
```

 ## API

After creating a Chrome driver and making sure you're authenticated, as shown above, you can use this function to interact with posts on your LinkedIn pages and groups.

```
from interactions import Posts

posts = Posts()
posts.start(chrome)
```

**Attributes:**

```
>> print(Posts.__doc__)

Interact with the LinkedIn posts.

    Params:
        number_of_posts_to_like (int): Number of posts to like (default = 5).
        number_of_post_comments_to_like (int): Number of comments to like for each post (default = 2).
        like_post_comments (bool): Start liking comments (default = False).
        auto_comment (bool): Post a positive comment for random posts (default = False).
        url (str): The page's url (default = 'https://www.linkedin.com/feed')
        short_sleep_range (tuple[float, float]): time.sleep(short range) (default = (0.5, 0.9)) 
        long_sleep_range (tuple[float, float]): time.sleep(long range) (default = (1.5, 4.9)) 

    Returns:
        None
```

<br><hr><br>

# 2. publishing

## CLI

This will allow you to publish a post with an image or text on your LinkedIn profile.


**options:**

- **--publish**: Enable the publishing option **(required)**.
- **--text**: The text content of the post **(optional)**.
- **--image-path**: The absolute path of the image **(optional)**.

💡 **Example:** If I want to publish a post with my image and greeting message.

```
autoln --env --headless --username LINKEDIN_EMAIL_ADDRESS --password LINKEDIN_PASSWORD --publish --text "Hi people!" --image-path C:\\images\me.png
```

## API

**Post text only**

```
from automate_linkedin.publish import Publish
p = Publish()
p.post(chrome, content="greeting!")
```

**Post text and image**

```
from automate_linkedin.publish import Publish
p = Publish()
p.image(chrome, r"C:\Users\selmi\Pictures\BloggersHood1.png", content="zfzazafazf")
```

<br><hr><br>
# 3. Network

Manage your network.

## 3.1. Follow people

You can follow up to 16 people each time.

### CLI

```
autoln --env --headless --username LINKEDIN_EMAIL_ADDRESS --password LINKEDIN_PASSWORD --follow-network
```

### API 

```
from automate_linkedin.networkk import Follow
follow = Follow()
follow.start(driver)
```

<br>

## 3.2. Connect with people

You can send invites up to 16 people each time.

### CLI

```
autoln --env --headless --username LINKEDIN_EMAIL_ADDRESS --password LINKEDIN_PASSWORD --connect-network
```

### API 

```
from automate_linkedin.networkk import Connect
connect = Connect()
connect.start(driver)
```

<br><br><br>

# 4. Environment variables

There many reasons for using environment variables in your projects, including:
- Easy configuration
- Better security
- Fewer production mistakes

So in your working directory, create a new file `.env` and place the secrets you'll use with this package.

**Exmaple**

```
LINKEDIN_EMAIL_ADDRESS=example@email.com
LINKEDIN_PASSWORD=password
```

Then you gonna use it throught the cli:

```
autoln --env --username LINKEDIN_EMAIL_ADDRESS --password LINKEDIN_PASSWORD
```

